<!DOCTYPE html>
<html>
{include file="head.html"}
<body>
<div class="body">
<div class="header">
    <a href="{$appkucun}?m=index"  class="left-btn"><span class="iconfont icon-back"></span></a>
    <div class="title">产品管理</div>
    <a href="{$appkucun}?m=kucun_product&a=add" class="right-btn"><span class="iconfont icon-upload"></span></a>
  </div>
<div class="main-body">
 <div class="tabs-border">
 	<a href="{$appkucun}?m=kucun_product" class="item {if get('status') neq 4}active{/if}">上线</a>
    <a href="{$appkucun}?m=kucun_product&status=4" class="item {if get('status') eq 4}active{/if}">下线</a>
 </div>
 <div class="plist">
  {foreach item=c from=$data}
  <div class="item" id="kc{$c.id}">
   
    
    	<div class="g-sd1">
        	<img src="{$c.imgurl|images_site}.100x100.jpg">
        </div>
        <div class="g-mn1">
        	<div class="g-mn1c">
            	 <div class="title">{$c.title}</div>
            	<div class="row-price">
               	 <span>价格￥{if $c.lower_price >0}{$c.lower_price}{else}{$c.price} 元{/if}</span>
                 <span>库存：<span class="total_num">{$c.total_num}</span></span>
                 <span>销量：{$c.buy_num}</span>
                </div>
                
                
     
    <div class="tool">
     
    {if $c.koudai eq 0}
    {if $c.status eq 2}
    <a href="javascript:;" url="{$appkucun}?m=kucun_product&a=forbid&ajax=1&id={$c.id}" class="forbid">下线</a>
    {else}
    <a href="javascript:;" url="{$appkucun}?m=kucun_product&a=pass&ajax=1&id={$c.id}" class="forbid">上线</a>
    <a href="javascript:;" url="{$appkucun}?m=kucun_product&a=delete&ajax=1&id={$c.id}" class="delete">删除</a>
    {/if}
    
    <a href="javascript:;"  onClick="addKuCun({$c.id})">库存管理</a>
    {/if} 
     </div>
            </div>
        </div>
   
    
    
  </div>
  {/foreach}
  </div>
  {if $pagelist}
  <div>{$pagelist}</div>
    {/if}
 

</div>
 

{include file='footer.html'}
<script>
function addKuCun(id){
	$.get("{$appkucun}?m=kucun_product&ajax=1&a=addkucun&id="+id,function(data){
		showbox("库存管理",data,200,60);
	});	
}

 

$(function(){
	$(document).on("click",".forbid",function(data){
		var obj=$(this);
		$.get($(this).attr("url"),function(data){
			if(data.error){
				skyToast(data.message);
			}else{
				obj.parents(".item").remove();
			}
		},"json")
	});
	
	$(document).on("click","#addKucun",function(data){
		var obj=$(this);
		$.get("{$appkucun}?m=kucun_product&ajax=1&a=addkucunSave&id="+$("#kucun_id").val()+"&num="+$("#kucun_num").val(),function(data){
			if(data.error){
				skyToast(data.message);
				
			}else{
				 
				$("#kc"+data.data.id+" .total_num").html(data.data.total_num);
				showboxClose();
			}
			
		},"json");
	});
	
	 
});
</script>
</div>
</body>
</html>